CISC 1110 Lab 24
For this lab, use the vet_record class
you wrote in Lab 23. As a reminder, vet_record
had three parts: an object of class animal_info, an
object of class owner_info, and a balance_due
field.
After creating the class definition, you wrote a declaration for an
array of objects of class vet_record. You
called it pet and it could hold info on 100 pets.
Now write two functions, one to
read values into the pet array of objects, and one to print the pet
array.
Start with the print_pets function,
because it is a little bit easier to write. The function will receive two
parameters, the array of objects of class vet_record,
and n, the number of objects in the array. Neither parameter is changed
in the function. The function will print the members of each object with
messages in front of each, like this:
pet: Rover age: 5 type of animal: dog weight: 10.6
owner: Joe Smith phone: 718-555-5555
balance due: 5.60
Now write the read_pets function. The
function will receive two parameters, the array of objects of class vet_record, and n, the number of objects in
the array. BOTH parameters are changed in the function. The function will read
in n and then read n sets of data values into the pets
array. The function will read from a file called lab24.dat which is available
on your class page, in the Labs section; download it and save it: http://www.sci.brooklyn.cuny.edu/~jones/cisc1110/Labs/lab24.txt
In the main program, call read_pets and
then call print_pets.
Now, write code in the main program to use the collection of data you've
just read in: